import 'package:wch/generated/json/base/json_convert_content.dart';
import 'package:wch/model/device_list_entity.dart';

DeviceListEntity $DeviceListEntityFromJson(Map<String, dynamic> json) {
  final DeviceListEntity deviceListEntity = DeviceListEntity();
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    deviceListEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    deviceListEntity.msg = msg;
  }
  final List<DeviceListData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<DeviceListData>(e) as DeviceListData)
      .toList();
  if (data != null) {
    deviceListEntity.data = data;
  }
  return deviceListEntity;
}

Map<String, dynamic> $DeviceListEntityToJson(DeviceListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension DeviceListEntityExtension on DeviceListEntity {
  DeviceListEntity copyWith({
    String? code,
    String? msg,
    List<DeviceListData>? data,
  }) {
    return DeviceListEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

DeviceListData $DeviceListDataFromJson(Map<String, dynamic> json) {
  final DeviceListData deviceListData = DeviceListData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    deviceListData.id = id;
  }
  final String? sickPersonId = jsonConvert.convert<String>(
      json['sickPersonId']);
  if (sickPersonId != null) {
    deviceListData.sickPersonId = sickPersonId;
  }
  final String? deviceBluetoothNumber = jsonConvert.convert<String>(
      json['deviceBluetoothNumber']);
  if (deviceBluetoothNumber != null) {
    deviceListData.deviceBluetoothNumber = deviceBluetoothNumber;
  }
  final String? number = jsonConvert.convert<String>(json['number']);
  if (number != null) {
    deviceListData.number = number;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    deviceListData.mobile = mobile;
  }
  final String? sickPersonSex = jsonConvert.convert<String>(
      json['sickPersonSex']);
  if (sickPersonSex != null) {
    deviceListData.sickPersonSex = sickPersonSex;
  }
  final String? sickPersonName = jsonConvert.convert<String>(
      json['sickPersonName']);
  if (sickPersonName != null) {
    deviceListData.sickPersonName = sickPersonName;
  }
  return deviceListData;
}

Map<String, dynamic> $DeviceListDataToJson(DeviceListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sickPersonId'] = entity.sickPersonId;
  data['deviceBluetoothNumber'] = entity.deviceBluetoothNumber;
  data['number'] = entity.number;
  data['mobile'] = entity.mobile;
  data['sickPersonSex'] = entity.sickPersonSex;
  data['sickPersonName'] = entity.sickPersonName;
  return data;
}

extension DeviceListDataExtension on DeviceListData {
  DeviceListData copyWith({
    String? id,
    String? sickPersonId,
    String? deviceBluetoothNumber,
    String? number,
    String? mobile,
    String? sickPersonSex,
    String? sickPersonName,
  }) {
    return DeviceListData()
      ..id = id ?? this.id
      ..sickPersonId = sickPersonId ?? this.sickPersonId
      ..deviceBluetoothNumber = deviceBluetoothNumber ??
          this.deviceBluetoothNumber
      ..number = number ?? this.number
      ..mobile = mobile ?? this.mobile
      ..sickPersonSex = sickPersonSex ?? this.sickPersonSex
      ..sickPersonName = sickPersonName ?? this.sickPersonName;
  }
}